home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-01 | 3.4 KB | 82 lines | [TEXT/ToyS] |
- -----------------------------------------------------------------------
- -- StarNine Technologies, Inc., hereby disclaims all copyright interest
- -- in the following source code by Joshua D. Baer (josh@starnine.com).
- --
- -- This source code is free and has been placed into the public domain.
- -- You can redistribute it, modify it (including these comments) and/or
- -- create derivative works from it as you see fit.
- --
- -- This source code is made available in the hope that it will be useful,
- -- but WITHOUT ANY WARRANTY; without even the implied warranty of
- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- -----------------------------------------------------------------------
-
- (* UNCOMMENT FOR TESTING *)
- --property s9MailFileName : "test message"
- (* END TESTING SECTION *)
-
- property trigger_succeeds : 1
- property trigger_fails : 0
- property trigger_error : -1
-
- property spool_folder : ""
-
- try
- tell application "Finder"
- if (exists of item spool_folder) is false then --see if stored property is valid
- if exists of item ((startup disk as string) & "ListSTAR/SMTP:ListSTAR Server") then
- copy (startup disk as string) & "ListSTAR/SMTP:Message Spool/SMTP:" to spool_folder
- else if exists of item ((startup disk as string) & "ListSTAR/MS:ListSTAR Server") then
- copy (startup disk as string) & "ListSTAR/MS:Message Spool/MS:" to spool_folder
- else if exists of item ((startup disk as string) & "ListSTAR/POP:ListSTAR Server") then
- copy (startup disk as string) & "ListSTAR/POP:Message Spool/POP:" to spool_folder
- else if exists of item ((startup disk as string) & "ListSTAR/QM:ListSTAR Server") then
- copy (startup disk as string) & "ListSTAR/QM:Message Spool/QM:" to spool_folder
- else
- error "The Spool Folder could not be found." number 100
- end if
- end if
- if (exists of file (spool_folder & s9MailFileName)) is false then --check spool file
- error "There is a problem with the spool file." number 101
- end if
- end tell
- set the_file to open for access file (spool_folder & s9MailFileName) --open file for reading
- set the_line to "Start" --initialize the_line
- repeat while (the first character of the_line) is not return
- set the_line to read the_file until return --read in one line
- ignoring case
- if the_line contains "Subject:" or the_line contains "Subj:" then
- close access the_file
- -- grab the value of the subject field
- try
- set OldDelims to AppleScript's text item delimiters
- set AppleScript's text item delimiters to ":"
- set the Subject to text item 2 of the_line
- set AppleScript's text item delimiters to OldDelims
- on error errMsg number errNum
- set AppleScript's text item delimiters to OldDelims
- error errMsg number errNum
- end try
- --if it's blank
- if the_line starts with (" " & return) or the_line starts with return then
- return trigger_succeeds
- --if it's not
- else
- return trigger_fails
- end if
- end if
- end ignoring
- end repeat
- -- if we've made it this far, there was no "Subject" RFC in the message so we return
- -- trigger_succeeds indicating that the subject was not present
- close access the_file
- return trigger_succeeds
- on error errMsg number errNum
- close access the_file
- if errNum is not -39 then --check for end of file
- display dialog (errMsg & return & errNum) buttons {"Cancel"} default button "Cancel" with icon stop
- return trigger_error
- else --reached end of file
- return trigger_fails
- end if
- end try